package service

import (
	"crow-samba/app/config"
	"crow-samba/app/pkg"
	"fmt"
)

func SendCmd(cmdString string) (response string, err error) {
	fmt.Println(response)
	cmd, err := pkg.CreatCmd("rsa", config.MyEnvs.IpAddr, config.MyEnvs.ServerName, config.MyEnvs.SshPort, "", config.MyEnvs.SshRsa, cmdString)
	if err != nil {
		return "", err
	}
	sshClient, err := cmd.ConnectSSH()
	response, err = cmd.SendCmd(sshClient)
	if err != nil {
		return "", err
	}
	return response, err
}
